<?php
class PassportController extends AbstractController
{
    public function __init()
    {
    }

    public function index()
    {
        $passportCls = new PassportModel();
        echo $passportCls->adminIsLogined();
    }

	/**
	 * 用户登陆
	 */
	public function login()
	{
	    $do = Functions::gpc('do', 'P', '');
	    $this->view->setAutoDisplay(false);
	    if($do == 'login')
	    {
	        $loginResult = array('loginAction' => false, 'success'=>false);
	        $passportCls = new PassportModel();
    	    $loginResult['success'] = $passportCls->adminIsLogined();
    	    if($this->requstMethod == 'POST')
    	    {
    	        $loginResult['loginAction'] = true;
    	        $username = Functions::sqlgpc('p_username', 'P', '');
    	        $password = Functions::sqlgpc('p_password', 'P', '');
    	        $loginResult['success'] = $passportCls->loginCheck($username, $password);
    	    }
    	    if($loginResult['success'])
    	    {
    	        
    	    }
    	    print_r($loginResult);
    	    $this->view->assign('loginResult', $loginResult);
    	    //$this->view->setThemeFile("");
	    }
	    else 
	    {
	        $this->view->display();
	    }
	}
	
    public function logout()
	{
	    $cookiepre = Config::getConfig('COOKIEPRE');
	    setcookie($cookiepre.'uid', null);
    	setcookie($cookiepre.'token', null);
	}
}